<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />
    <title>美策平台</title>
    <link rel="icon" type="image/png" href="/img/icon.png">
    <link rel="stylesheet" type="text/css" href="../datepicker/jquery-ui.min.css">
    <link rel="stylesheet" type="text/css" href="../css/app.css">
    <link rel="stylesheet" type="text/css" href="../css/orderGrad.css">
    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <script type="text/javascript" src="/h5/js/all.js"></script>
</head>
<body>
    <!-- 订单对接 -->
    <div class="orderDockingPage">
        <div class="orderParamTitle">
            订单对接
            <img src="../images/return.png" class="orderRtns" onclick="history.go(-1)">
        </div>
        <div style="height:1.066667rem"></div>
        <div class="content">
            <ul class="list myOrderList">

            </ul>
        </div>
    </div>
    <script type="text/javascript" src="../js/app.js"></script>
    <script type="text/javascript" src="../js/orderPageChange.js"></script>
    <script type="text/javascript" src="../js/alertMsg.js"></script>
    <script>
      $('.orderDockingPage .detail').click(function() {
          window.location.href = 'orderProductionDocumentary.html'
      })
    </script>
</body>
</html>
<script>
    var userInfo = JSON.parse(localStorage.getItem('userInfo'));
    var app_access = userInfo.app_access;
    var token = userInfo.token;
    function pushOrder(id) {
        var dataId = $(this).parent().parent().attr('data-id');
        var data = {
            id: id,
            app_access: app_access,
            token: token
        }
        $.ajax({
            url: '/api/order/my/pushing',
            data: data,
            type: 'post',
            dataType: 'json',
            success: function(data) {
                if(data.code < 0){
                    alertMsg(data.msg)
                }else{
                    alertMsg(data.msg)
                    window.location.href='orderPushDocking.html'
                }
            },
            err: function(err) {
                alertMsg(err)
            }
        })
    }
    $(function() {
        getOrderList();
        function getOrderList() {
            var data = {
                app_access: app_access,
                token: token
            }
            $.ajax({
                url: '/api/order/my/push',
                data: data,
                type: 'get',
                dataType: 'json',
                success: function(data) {
                    var listHtml = '';
                    var status = '';
                    var order_status = '';

                    if (data.data.length == 0) {
                        alertMsg('暂无订单发布')
                        return false
                    }
                    data = data.data;
                    for (var i = 0; i < data.length; i++) {
                            var com_name = '接单公司';
                            //$item['status'] = 0; //生产订单的流程状态 0 不显示
                            //$item['order_status'] = $t['status']; //抢单中还是生产中  1未支付，2已支付未抢单，3抢单中，4抢单成功  5抢单失败
                            //$item['is_del'] = $t['order_detail']['del']; // 1删除（已取消）
                            if(data[i].is_del == 1){
                                status = '已取消';
                                order_status = '';

                            }else if(data[i].status == 1){
                                status = '草稿中';
                                order_status = '<span onclick="pushOrder('+data[i].id+')">确认发布</span>';
                            }else if(data[i].status == 2){
                                status = '抢单中';
                                order_status = '';
                                com_name = '抢单公司';
                            }else if(data[i].status == 3){
                                if(data[i].order_status == 1){
                                    status = '生产中';
                                    order_status = '原料发出';
                                }else if(data[i].order_status == 2){
                                    status = '生产中';
                                    order_status = '等待对方接收原料';
                                }else if(data[i].order_status == 3){
                                    status = '生产中';
                                    order_status = '<a href="orderProductionDocumentary.html?id='+data[i].id+'">跟单开始</a>';
                                }else if(data[i].order_status == 4){
                                    status = '生产中';
                                    order_status = '跟单开始';
                                }else if(data[i].order_status == 5){
                                    status = '生产中';
                                    order_status = '跟单开始';
                                }else if(data[i].order_status == 6){
                                    status = '运输中';
                                    order_status = '<a href="shippingTransportation2.html?id='+data[i].id+'">确认签收</a>';
                                }else if(data[i].order_status == 7){
                                    status = '待评价';
                                    order_status = '<a href="shippingOrderEvaluate.html?id='+data[i].id+'">马上评价</a>';
                                }else if(data[i].order_status == 8){
                                    status = '已完成';
                                    order_status = '';
                                }else if(data[i].order_status == 9){
                                    status = '已完成';
                                    order_status = '';
                                }else{
                                    status = '无人接单';
                                    order_status = '';
                                    com_name = '抢单公司';
                                }
                            }
console.log(com_name)
                        listHtml += "<li class=\"detail\">\n" +
                            "                    <span class=\"detail__span\" style=background-image:url("+data[i].img+") alt=\"\"></span>                   \n" +
                            "                    <ul>\n" +
                            "                        <li>\n" +
                            "                            <span>订单名称：</span>\n" +
                            "                            <span>"+data[i].title+"</span>\n" +
                            "                            <span>"+status+"</span>\n" +
                            "                        </li>\n" +
                            "                        <li  data-id="+data[i].id+">\n" +
                            "                            <span>"+com_name+"：</span>\n" +
                            "                            <span>"+data[i].company+"</span>\n" +
                            "                            <span>"+order_status+"</span>\n" +
                            "                        </li>\n" +
                            "                        <li>\n" +
                            "                            <span>交货期限：</span>\n" +
                            "                            <span>"+data[i].exptime+"</span>\n" +
                            "                        </li>\n" +
                            "                    </ul>\n" +
                            "                </li>";
                    }
                    $(".myOrderList").html(listHtml);
                },
                err: function(err) {
                    alertMsg(err)
                }
            })
        }
    })
</script>